﻿using Microsoft.EntityFrameworkCore;
using SmartApplication.Domain.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;

namespace SmartApplication.Infrastructure
{
    public class MyDbContext:DbContext
    {
        public MyDbContext(DbContextOptions<MyDbContext> options):base(options)
        {
            
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<AccountModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<RoleModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<SourceModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<FeedModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<CompaniesModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<KillModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<BusinessModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<ProcessingModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<FoodSafetyMode>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<VendorModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<CorporateModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<MaterialsModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<ExcipientsModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<AdditiveModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<StuffModel>().HasQueryFilter(b => !b.IsDeleted);
            modelBuilder.Entity<HealthModel>().HasQueryFilter(b => !b.IsDeleted);
        }

        /// <summary>
        /// 账号实体
        /// </summary>
        public DbSet<AccountModel> AccountModels { get; set; }
        /// <summary>
        /// 角色实体
        /// </summary>
        public DbSet<RoleModel> RoleModels {  get; set; }
        /// <summary>
        /// 溯源基本信息
        /// </summary>
        public DbSet<SourceModel> SourceModels {  get; set; }
        /// <summary>
        /// 养殖详细信息
        /// </summary>
        public DbSet<FeedModel> FeedModels { get; set; }
        public DbSet<HealthModel> HealthModels { get; set; }
        /// <summary>
        /// 养殖企业信息
        /// </summary>
        public DbSet<CompaniesModel> CompaniesModels {  get; set; }
        /// <summary>
        /// 屠宰详细信息
        /// </summary>
        public DbSet<KillModel> KillModels { get; set; }
        /// <summary>
        /// 屠宰企业信息
        /// </summary>
        public DbSet<BusinessModel> BusinessModels {  get; set; }
        /// <summary>
        /// 深加工信息
        /// </summary>
        public DbSet<ProcessingModel> ProcessingModels { get; set; }
        /// <summary>
        /// 食品安全图片
        /// </summary>
        public DbSet<FoodSafetyMode> FoodSafetyModes {  get; set; }
        /// <summary>
        /// 供应商信息
        /// </summary>
        public DbSet<VendorModel> VendorModels {  get; set; }
        /// <summary>
        /// 加工企业信息
        /// </summary>
        public DbSet<CorporateModel> CorporateModels { get; set; }
        /// <summary>
        /// 原料表
        /// </summary>
        public DbSet<MaterialsModel> MaterialsModels {  get; set; }
        /// <summary>
        /// 辅料表
        /// </summary>
        public DbSet<ExcipientsModel> ExcipientsModels {  get; set; }
        /// <summary>
        /// 添加剂表
        /// </summary>
        public DbSet<AdditiveModel> AdditiveModels { get; set; }
        /// <summary>
        /// 包材表
        /// </summary>
        public DbSet<StuffModel> StuffModels { get; set; }
    }
}
